#include <algorithm>
#include <cctype> //ctype无法打开，包含tolower()函数和ispunct函数
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <set>
#include <string>
#include <utility> //保存pair的头文件
#include <vector>

using namespace std;

int main(int argc, char **argv) {
  string author = "机械先驱";
  multimap<string, string> Library;
  Library.insert(make_pair(author, "灭世者的帽子"));
  Library.insert(make_pair(author, "法穿杖"));
  Library.insert(make_pair(author, "法穿鞋"));
  Library.insert(make_pair(author, "冰杖"));
  Library.insert(make_pair(author, "巫妖之祸"));
  Library.insert(make_pair(author, "海克斯科技核心"));

  auto it1 = Library.find(author); //返回第一个关键字为author的迭代器
  auto it2 = Library.count(author); //返回关键词为author的元素数量

  while (it2) {
    if (it1->second == "海克斯科技核心") {
      Library.erase(it1); //直接删除此关键字值对，传入参数为指向它的迭代器
      break; //需要,不然下面调用到已经删除的迭代器，会出粗
    }
    ++it1;
    --it2;
  }

  multimap<string, string>::iterator it3 = Library.begin();
  for (; it3 != Library.end(); ++it3) {
    cout << it3->first << "的宝贝儿：" << it3->second << endl;
  }

  return 0;
}